import React, { Component } from "react";
import qs from "querystring";

const news = [
  {
    id: "001",
    content: "你好vue"
  },
  {
    id: "002",
    content: "你好react"
  },
  {
    id: "003",
    content: "你好angular"
  }
];
export default class index extends Component {
  render() {
    console.log(this.props.location.state, "11111");
    //1.路由组件接收params参数
    //let { id, title } = this.props.match.params;

    //2.路由组件接收search参数
    // let { id, title } = qs.parse(this.props.location.search.slice(1));
    // let id = "001";
    // let title = "22";
    // let content = "33";
    //let content = news.find(v => v.id === id).content;
    //3.路由组件接收state参数
    let { id, title } = this.props.location.state;
    let content = news.find(v => v.id === id).content;
    return (
      <>
        <div>Id:{id}</div>
        <div>Titile:{title}</div>
        <div>Content:{content}</div>
      </>
    );
  }
}
